package com.dqp.cslggroup;

import android.annotation.SuppressLint;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import com.dqp.cslggroup.UI.MyApplication;
import com.dqp.cslggroup.bean.student;

import java.util.ArrayList;
import java.util.List;


public class Fragment_Two extends Fragment {
    private RecyclerView mRecyclerView;

    @SuppressLint("InflateParams")
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.diary_viewpager_layout, null);
        mRecyclerView = view.findViewById(R.id.rec);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
        mRecyclerView.setLayoutManager(layoutManager);
        initList();
        return view;

    }

    @SuppressLint("HandlerLeak")
    private void initList() {
        ArrayList<String> dataList=new ArrayList<>();
        List<student> studentList=MyApplication.getDaoInstant().getStudentDao().loadAll();
        if (studentList.size()>0){
            dataList.add("姓名："+studentList.get(0).getXh());
            dataList.add("学号："+studentList.get(0).getXm());
            dataList.add("性别："+studentList.get(0).getXb());
//            dataList.add("生日："+studentList.get(0).getSr());
            dataList.add("生源："+studentList.get(0).getSyd());
            dataList.add("年级："+studentList.get(0).getRxnf());
            dataList.add("班级："+studentList.get(0).getBj());
            dataList.add("专业："+studentList.get(0).getZy());
            dataList.add("学院："+studentList.get(0).getXy());
//            dataList.add("师范："+studentList.get(0).getSf());
//            dataList.add("政治面貌："+studentList.get(0).getZzmm());
        }
        Adapter_Diary mAdapter = new Adapter_Diary(dataList);
        mRecyclerView.setAdapter(mAdapter);
    }


}

